﻿using Sidvall.Security;
using System.Threading.Tasks;

namespace Sidvall.Web.Security
{
    public class UserEmailValidatorFactory : Sidvall.Reflection.IInstanceItemFactory<IIdentityValidator>
    {
        #region Public Members

        #region CreateAsync

        public async Task<IIdentityValidator> CreateAsync(string context)
        {
            var factoryContext = UserEmailValidatorFactoryContext.Deserialize(context, new UserEmailValidatorFactoryContext());
            var item = new UserEmailValidator(factoryContext.AuthorityUserInfoEndpoint, factoryContext.IgnoredUsers);
            return await Task.FromResult(item);
        }

        #endregion

        #endregion
    }
}
